package org.styx.rabbitmq.component;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.styx.rabbitmq.config.TopicConfig;
import org.styx.rabbitmq.entity.User;

/**
 * @date 2021/10/14
 * @auther uranus
 */
@Component
public class TopicSender {
    @Autowired
    private AmqpTemplate amqpTemplate;

    public void sendTopicQueue(){
        User user=new User();
        user.setId("1001");
        user.setUserName("张三");

        User user1=new User();
        user1.setId("1002");
        user1.setUserName("李四");

        this.amqpTemplate.convertAndSend(TopicConfig.TOPIC_EXCHANG,"topic" +
                ".message",user);

        this.amqpTemplate.convertAndSend(TopicConfig.TOPIC_EXCHANG,"topic" +
                ".message2",user1);

    }
}
